namespace YiDa.Repository.EntityFramework.Test.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Schools",
                c => new
                    {
                        ID = c.Guid(nullable: false, identity: true),
                        Name = c.String(),
                        Address = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.SchoolClasses",
                c => new
                    {
                        ID = c.Guid(nullable: false, identity: true),
                        Name = c.String(),
                        MasterTeacher = c.String(),
                        School_ID = c.Guid(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Schools", t => t.School_ID)
                .Index(t => t.School_ID);
            
            CreateTable(
                "dbo.Students",
                c => new
                    {
                        ID = c.Guid(nullable: false, identity: true),
                        Age = c.Int(nullable: false),
                        Name = c.String(),
                        School_ID = c.Guid(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.SchoolClasses", t => t.School_ID)
                .Index(t => t.School_ID);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Students", new[] { "School_ID" });
            DropIndex("dbo.SchoolClasses", new[] { "School_ID" });
            DropForeignKey("dbo.Students", "School_ID", "dbo.SchoolClasses");
            DropForeignKey("dbo.SchoolClasses", "School_ID", "dbo.Schools");
            DropTable("dbo.Students");
            DropTable("dbo.SchoolClasses");
            DropTable("dbo.Schools");
        }
    }
}
